package com.demo.zhlg.controller;

import com.demo.zhlg.util.Result;
import com.mybatisflex.core.paginate.Page;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.demo.zhlg.entity.TaskOrders;
import com.demo.zhlg.service.TaskOrdersService;

import java.io.Serializable;
import java.util.List;

/**
 *  控制层。
 *
 * @author lenovo
 * @since 2025-04-26
 */
@RestController
@RequestMapping("/taskOrders")
public class TaskOrdersController {

    @Autowired
    private TaskOrdersService taskOrdersService;

    @GetMapping("getOrders")
    public Object list() {
        return taskOrdersService.getOrders();
    }

    @GetMapping("searchOrders")
    public Object searchOrders(@RequestParam String keyword){
        return taskOrdersService.searchOrders(keyword);
    }

    @GetMapping("getMyPublishedOrders")
    public Object getMyPublishedOrders(){
        return taskOrdersService.getMyPublishedOrders();
    }

    @GetMapping("getMyAcceptedOrders")
    public Object getMyAcceptedOrders(){
        return taskOrdersService.getMyAcceptedOrders();
    }

    @GetMapping("getOrderDetail")
    public Object getOrderDetail(@RequestParam Integer orderId){
        return Result.success(taskOrdersService.getById(orderId));
    }

    @PostMapping("cancelOrder")
    public Object cancelOrder(@RequestParam Integer orderId){
        return taskOrdersService.cancelOrder(orderId);
    }

    @PostMapping("completeOrder")
    public Object completeOrder(@RequestParam Integer orderId){
        return taskOrdersService.completeOrder(orderId);
    }
}
